#include "apue.h"
#include <fcntl.h>

int main() {
    int fd, ret;

    const char *s1 = "abcdefghij";
    const char *s2 = "ABCDEFGHIJ";

    fd = open("test.hole", O_WRONLY | O_CREAT | O_TRUNC, 0755);
    if (-1 == fd)
        err_sys("open file error");

    if (write(fd, s1, 10) != 10)
        err_sys("write s1 error");
    if ((ret = lseek(fd, 0, SEEK_CUR)) < 0)
        err_sys("lseek error");
    printf("localtion: %d\n", ret);

    if ((ret = lseek(fd, 1000, SEEK_SET)) < 0)
        err_sys("lseek error");
    printf("localtion: %d\n", ret);

    if (write(fd, s2, 10) != 10)
        err_sys("write s2 error");

    close(fd);
    return 0;
}
